/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package supportlearning.entity;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author Huy
 */
@Entity
@Table(name = "StudentResult", catalog = "SupportLearningDB", schema = "dbo")
@NamedQueries({
    @NamedQuery(name = "StudentResult.findAll", query = "SELECT s FROM StudentResult s"),
    @NamedQuery(name = "StudentResult.findByStudentId", query = "SELECT s FROM StudentResult s WHERE s.studentResultPK.studentId = :studentId"),
    @NamedQuery(name = "StudentResult.findByAsmId", query = "SELECT s FROM StudentResult s WHERE s.studentResultPK.asmId = :asmId"),
    @NamedQuery(name = "StudentResult.findByMark", query = "SELECT s FROM StudentResult s WHERE s.mark = :mark"),
    @NamedQuery(name = "StudentResult.findByNotes", query = "SELECT s FROM StudentResult s WHERE s.notes = :notes"),
    @NamedQuery(name = "StudentResult.findByUrlFile", query = "SELECT s FROM StudentResult s WHERE s.urlFile = :urlFile")})
public class StudentResult implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected StudentResultPK studentResultPK;
    @Column(name = "Mark", precision = 53)
    private Double mark;
    @Column(name = "Notes", length = 50)
    private String notes;
    @Basic(optional = false)
    @Column(name = "UrlFile", nullable = false, length = 100)
    private String urlFile;
    @JoinColumn(name = "StudentId", referencedColumnName = "StudentId", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private StudentProfile studentProfile;
    @JoinColumn(name = "AsmId", referencedColumnName = "AsmId", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Assignment assignment;

    public StudentResult() {
    }

    public StudentResult(StudentResultPK studentResultPK) {
        this.studentResultPK = studentResultPK;
    }

    public StudentResult(StudentResultPK studentResultPK, String urlFile) {
        this.studentResultPK = studentResultPK;
        this.urlFile = urlFile;
    }

    public StudentResult(String studentId, int asmId) {
        this.studentResultPK = new StudentResultPK(studentId, asmId);
    }

    public StudentResultPK getStudentResultPK() {
        return studentResultPK;
    }

    public void setStudentResultPK(StudentResultPK studentResultPK) {
        this.studentResultPK = studentResultPK;
    }

    public Double getMark() {
        return mark;
    }

    public void setMark(Double mark) {
        this.mark = mark;
    }

    public String getNotes() {
        return notes;
    }

    public void setNotes(String notes) {
        this.notes = notes;
    }

    public String getUrlFile() {
        return urlFile;
    }

    public void setUrlFile(String urlFile) {
        this.urlFile = urlFile;
    }

    public StudentProfile getStudentProfile() {
        return studentProfile;
    }

    public void setStudentProfile(StudentProfile studentProfile) {
        this.studentProfile = studentProfile;
    }

    public Assignment getAssignment() {
        return assignment;
    }

    public void setAssignment(Assignment assignment) {
        this.assignment = assignment;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (studentResultPK != null ? studentResultPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof StudentResult)) {
            return false;
        }
        StudentResult other = (StudentResult) object;
        if ((this.studentResultPK == null && other.studentResultPK != null) || (this.studentResultPK != null && !this.studentResultPK.equals(other.studentResultPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "supportlearning.entity.StudentResult[studentResultPK=" + studentResultPK + "]";
    }

}
